529
class Solution {
    int row = 0;
    int col = 0;

    public char[][] updateBoard(char[][] board, int[] click) {
        row = board.length;
        col = board[0].length;
        dfs(board, click[0], click[1]);
        return board;
    }

    public void dfs(char[][] board, int x, int y) {
        switch(board[x][y]) {
            case 'M' 
                board[x][y] = 'X';
                break;
            case 'E' 
                int count = checkAround(board, x, y);
                if (count == 0) {
                    board[x][y] = 'B';
                    x--;
                    y--;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                    y++;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                    y++;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                    x++;
                    y -= 2;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                    y += 2;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                    x++;
                    y -= 2;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                    y++;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                    y++;
                    if (x = 0 && x  row && y = 0 && y  col && board[x][y] == 'E') {
                        dfs(board, x, y);
                    }
                } else {
                    board[x][y] = (char)(count+'0');
                }
                break;
            default  break;
        }
    }

    public int checkAround(char[][] board, int x, int y) {
        int count = 0;
        for (int i = x-1 = 0  x-1  0; i  row && i  x-1+3; i++) {
            for (int j = y-1 = 0  y-1  0; j  col && j  y-1+3; j++) {
                if (board[i][j] == 'M') {
                    count++;
                }
            }
        }
        return count;
    }
}
请补全预设代码中判断质数的方法。
输入描述：
一个大于1的整数
输出描述：
true/false


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        Scanner scan = new Scanner(System.in);
        int number = scan.nextInt();
        System.out.println(main.isPrimeNumber(number));
    }

    public Boolean isPrimeNumber(int number) {

        //write your code here......
        for (int i = 2; i < number; i++){
            if (number % i == 0){
                return false;
            }
        }
        return true;
    }
}
//五子棋
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
char[][] arr = new char[20][20];
for (int i = 0; i < 20; i++) {
arr[i] = in.next().toCharArray();
}
boolean is_true = false;
for (int i = 0; i < 20 && !is_true; i++) {
for (int j = 0; j < 20 && !is_true; j++) {
if (arr[i][j] != '.') {
//判断是否有五子连珠
//列
if (fun2(arr, i, j)) {
is_true = true;
continue;
}
//右斜
if (fun3(arr, i, j)) {
is_true = true;
continue;
}
//左斜
if (fun4(arr, i, j)) {
is_true = true;
continue;
}
//行
int[] tmp = new int[]{i, j};
if (!fun1(arr, tmp)) {
j = tmp[1];
} else {
is_true = true;
continue;
}
}
}
}
System.out.println(is_true ? "Yes" : "No");
}
}
public static boolean fun4(char[][] arr, int i, int j) {
if (j < 4 || i > 15) {
return false;
}
int count = 0;
char c = arr[i][j];
for (; j >= 0 && i >= 0; i--, j--) {
if (arr[i][j] == c) {
count++;
} else {
break;
}
}
if (count >= 5) {
return true;
}
return false;
}
public static boolean fun3(char[][] arr, int i, int j) {
if (j > 15 || i > 15) {
return false;
}
int count = 0;
char c = arr[i][j];
for (; j < 20 && i < 20 ; i++, j++) {
if (arr[i][j] == c) {
count++;
} else {
break;
}
}
if (count >= 5) {
return true;
}
return false;
}
public static boolean fun2(char[][] arr, int i, int j) {
if (i > 15) {
return false;
}
int count = 0;
char c = arr[i][j];
for (; i < 20; i++) {
if (arr[i][j] == c) {
count++;
} else {
break;
}
}
if (count >= 5) {
return true;
}
return false;
}
public static boolean fun1(char[][] arr, int[] ij) {
if (ij[1] > 15) {
return false;
}
int count = 0;
char c = arr[ij[0]][ij[1]];
for (; ij[1] < 20; ij[1]++) {
if (arr[ij[0]][ij[1]] == c) {
count++;
} else {
break;
}
}
ij[1]--;
if (count >= 5) {
return true;
}
return false;
}
}